package com.example.demoddd.application.in.rest.controller;


import com.example.demoddd.application.dto.UserDto;
import com.example.demoddd.domain.userauth.services.UserService;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/users")
@RequiredArgsConstructor
public class UserController {
    private final UserService userService;
    //private final AuthenticationManager authenticationManager;


    @PreAuthorize("hasAuthority('/users/register')")
    @PostMapping("/register")
    public ResponseEntity<UserDto> registerUser(@RequestBody UserDto.CreateUserDto createUserDto) {
        UserDto userDto = userService.createUser(createUserDto);
        return ResponseEntity.ok(userDto);
    }


}

